<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<if condition="$add_from eq 0">
				<li><a href="{:U('Admin/Live/index')}">直播列表</a></li>
				<li><a href="{:U('Admin/Live/add')}">添加直播</a></li>
			</if>
			<li class="active"><a href="{:U('Admin/Live/news_relation', array('live_id'=>$live_id))}">相关新闻</a></li>
		</ul>
		<form class="well form-search js-ajax-form" id="add_relation_form" method="post" action="{:U('Admin/Live/news_relation_add')}">
			URL： 
			<input type="text" name="news_url" style="width: 180px;" value="">
			权重： 
			<input type="text" name="news_weight" style="width: 100px;" value="70" >
			<input type="hidden" name="live_id" value="{$live_id}">
			<button type="submit" class="btn btn-primary js-ajax-submit">添加</button>
		</form>
		<form class="js-ajax-form" action="" method="post">
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th>标题名称</th>
					<th>编辑</th>
					<th>来源</th>
					<th>时间</th>
					<th>权重</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<foreach name="data" item="vo">
				<tr>
					<td>{$vo.title}</td>
					<td>{$vo.creator_name}</td>
					<td>{$vo.source_name}</td>
					<td>{$vo.create_time}</td>
					<td>{$vo['weight']}
					<a style="float:right;" href='javascript:void(1);' onclick='edit_news_weight({$vo["relation_id"]})' >修改</a>
					</td>
					<td>
					   <a href="{:U('Admin/Live/delete_news_relation', array('relation_id'=>$vo['relation_id'], 'live_id'=>$_GET['live_id']))}" class="js-ajax-dialog-btn">删除</a>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		</form>
		<div class="pagination">{$page}</div>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script src="__PUBLIC__/js/layer/layer.js"></script>
	<script>
	$(document).ready(function(){
		
	});
	function edit_news_weight(relation_id){
		//prompt层
		 layer.prompt({
		   title: '输入权重',
		   value:name,
		   formType: 0 //prompt风格，支持0-2
		 }, function(weight){
			 if(null == weight || '' == weight){
				 layer.msg('权重不能为空！');
				 return false;
			 }
			 var g = /^[1-9]*[1-9][0-9]*$/;
             if(!g.test(weight) || weight > 255){
             	layer.msg('权重必须是0到255的整数！');
         		return false;
             }
			 $.post('{:U("Admin/Live/edit_news_weight")}', {relation_id:relation_id, weight:weight}, function(result){
				 if(result.status == '1'){
				 	layer.msg('修改成功！');
				 	reloadPage(window);
				 }
		     });
		 });
	}
	</script>
</body>
</html>